import instance from "@/request/request";
import type { Res } from '@/request/ResultApi';

//获取所有订单
export const getAllOrder = (size: number, current: number,orderState:number,customerName:String,orderId:number,timeOrderBy:number): Res<null> =>
   {
    let srt=""
    if(orderId!=-1&&!Number.isNaN(orderId))srt+="&orderId="+orderId
    if(customerName!='')srt+="&customerName="+customerName
    if(orderState!=-1)srt+="&orderState="+orderState
    return instance.get(`/orders/all?size=${size}&current=${current}&timeOrderBy=${timeOrderBy}${srt}`);
   } 

//添加订单
export const addOrder = (data: {
    description: String,
    customerName: String,
}): Res<null> => instance.post("/orders/add", data);

//修改订单
export const updateOrder = (data: {
    orderId:String,
    description: String,
    customerName: String,
}): Res<null> => instance.post("/orders/update", data);

//删除订单
export const removeOrder = (orderId: number): Res<null> =>
    instance.post(`/orders/delete?orderId=${orderId}`);

//批量删除订单
export const removeOrders = (data: []): Res<null> => instance.post("/orders/deletes", data);